import React, { Component } from "react";
import {
  Table,
  Space,
  Form,
  message,
  Tooltip,
  Input,
  InputNumber,
  Tabs,
  Button,
  Select,
  Tag,
} from "antd";
import {
  EditOutlined,
  DeleteOutlined,
  PlusOutlined,
  DeleteFilled,
} from "@ant-design/icons";
import NewModal from "../../componentJsx/common/NewModal";
import HasPermi from "../../componentJsx/common/hasPermi";
import AdvancedSearchForm from "../../componentJsx/common/searchForm";
import "antd/dist/antd.css";
import "../../componentCss/component.css";
import {
  getConfigurationData,
  addConfigurationData,
  editConfigurationData,
  deleteConfigurationData,
  getExamData,
  addExamData,
  editExamData,
  deleteExamData,
  getMapData,
  addMapData,
  deleteMapData,
  editMapData,
} from "../../api2";
import "moment/locale/zh-cn";
import {
  getDictionaryLabel,
  getExamDictionaryLabel,
} from "../../rudexRou/OperatesCookie";
class Index extends Component {
  constructor (props) {
    super(props);
    this.state = {
      deleteModalVisible: false, //删除的模态框
      modifyModalVisible: false, //修改的模态框
      addModalVisible: false, //添加编码的模态框
      addParentModalVisible: false, //添加父项的模态框

      addMapVisible: false,
      editMapVisible: false,
      deleteMapVisible: false,
      checkMapVisible: false,

      addRelationVisible: false,
      editRelationVisible: false,
      deleteRelationVisible: false,

      confirmLoading: false, //确认按钮异步等待
      tableLoading: false,
      selectedRow: {},
      mapSelectedRow: [],
      mapSelectedRowKeys: [],
      relationSelectedRow: [],
      relationSelectedRowKeys: [],
      tableData: [],
      mapData: [],
      relationData: [],

      tableColumns: [
        {
          title: "编码",
          dataIndex: "code",
          ellipsis: true,
          key: "code",
          // width: 200,
          render: (text, record) =>
            this.state.tableData.indexOf(record) >= 0 || record.children ? (
              <strong>{text}</strong>
            ) : (
              <>{text}</>
            ),
        },
        {
          title: "名称",
          dataIndex: "name",
          ellipsis: true,
          key: "name",
          // width: "20%",
          render: (text, record) =>
            this.state.tableData.indexOf(record) >= 0 || record.children ? (
              <strong>{text}</strong>
            ) : (
              <>{text}</>
            ),
        },
        {
          title: "描述",
          ellipsis: true,
          dataIndex: "description",
          // width: "30%",
          key: "description",
          render: (text, record) =>
            this.state.tableData.indexOf(record) >= 0 || record.children ? (
              <strong>{text}</strong>
            ) : (
              <>{text}</>
            ),
        },
        {
          title: "排序",
          ellipsis: true,
          dataIndex: "sort",
          width: 100,
          key: "sort",
          render: (text, record) =>
            this.state.tableData.indexOf(record) >= 0 || record.children ? (
              <strong>{text}</strong>
            ) : (
              <>{text}</>
            ),
        },
        {
          title: "操作",
          dataIndex: "handle",
          width: 150,
          align: "center",
          render: (_, record) =>
            this.state.tableData.indexOf(record) >= 0 ? (
              <>
                <Tooltip title="修改">
                  <span>
                    <HasPermi
                      bottonData={{
                        type: "link",
                        size:"small",
                        interceptor: "tmfs:configuration:edit",
                        icon: <EditOutlined />,
                        clickFn: (e) => {
                          e.stopPropagation();
                          this.showModal("modify", record);
                        },
                      }}
                    />
                  </span>
                </Tooltip>
                <Tooltip title="添加枚举值">
                  <span>
                    <HasPermi
                      bottonData={{
                        type: "link",
                        size:"small",
                        interceptor: "tmfs:configuration:add",
                        icon: <PlusOutlined />,
                        clickFn: (e) => {
                          e.stopPropagation();
                          this.showModal("add", record);
                        },
                      }}
                    />
                  </span>
                </Tooltip>
                <Tooltip title="删除">
                  <span>
                    <HasPermi
                      bottonData={{
                        type: "link",
                        size:"small",
                        interceptor: "tmfs:configuration:del",
                        icon: <DeleteOutlined style={{ color: "red" }} />,
                        clickFn: (e) => {
                          e.stopPropagation();
                          this.showModal("delete", record);
                        },
                      }}
                    />
                  </span>
                </Tooltip>
              </>
            ) : (
              <>
                <Tooltip title="修改">
                  <span>
                    <HasPermi
                      bottonData={{
                        type: "link",
                        size:"small",
                        interceptor: "tmfs:configuration:edit",
                        icon: <EditOutlined />,
                        clickFn: (e) => {
                          e.stopPropagation();
                          this.showModal("modify", record);
                        },
                      }}
                    />
                  </span>
                </Tooltip>
                <Tooltip title="删除">
                  <span>
                    <HasPermi
                      bottonData={{
                        type: "link",
                        size:"small",
                        interceptor: "tmfs:configuration:del",
                        icon: <DeleteOutlined style={{ color: "red" }} />,
                        clickFn: (e) => {
                          e.stopPropagation();
                          this.showModal("delete", record);
                        },
                      }}
                    />
                  </span>
                </Tooltip>
              </>
            ),
        },
      ],
      mapColumns: [
        {
          title: "序号",
          dataIndex: "index",
          key: "index",
          width: 120,
          render: (text, record, index) =>
            record.parentId == -1 ? (
              <strong>
                {`${(this.state.mapPage - 1) * this.state.mapPageSize +
                  (index + 1)}
                `}
              </strong>
            ) : (
              index + 1
            ),
        },
        {
          title: "映射名称",
          dataIndex: "content",
          key: "content",
          ellipsis: true,
          width: 200,
          render: (text, record) =>
            record.parentId == -1 ? (
              <div style={{ minWidth: 200 }}>
                <strong>
                  {getDictionaryLabel("postCategory", record.postTypeCode) +
                    " - " +
                    getDictionaryLabel("examType", record.examTypeCode)}
                </strong>
              </div>
            ) : (
              text
            ),
        },
        {
          title: "描述",
          dataIndex: "description",
          key: "description",
          ellipsis: true,
          // width: 150,
        },

        {
          title: "创建人姓名",
          dataIndex: "createEmpName",
          key: "createEmpName",
          ellipsis: true,
          width: 100,
        },
        {
          title: "创建人工号",
          dataIndex: "createEmpNo",
          key: "createEmpNo",
          ellipsis: true,
          width: 100,
        },
        {
          title: "创建时间",
          dataIndex: "createDate",
          key: "createDate",
          ellipsis: true,
          width: 100,
        },
        {
          title: "操作",
          dataIndex: "handle",
          width: 150,
          align: "center",
          render: (_, record) => {
            let flag = false;
            if (this.state.mapData.indexOf(record) >= 0) {
              flag = true;
            }
            if (flag) {
              return (
                <Space>
                  <Tooltip title="修改">
                    <div>
                      <HasPermi
                        bottonData={{
                          type: "link",
                          interceptor: "tmfs:configuration:edit",
                          icon: <EditOutlined />,
                          clickFn: (e) => {
                            e.stopPropagation();
                            this.showModal("editMap", record);
                            this.setState({ status: "OMP岗位映射" });
                          },
                        }}
                      />
                    </div>
                  </Tooltip>
                  <Tooltip title="添加">
                    <div>
                      <HasPermi
                        bottonData={{
                          type: "link",
                          interceptor: "tmfs:configuration:del",
                          icon: <PlusOutlined />,
                          clickFn: (e) => {
                            e.stopPropagation();
                            this.showModal("addMap", record);
                            this.setState({ status: "OMP岗位类型值" });
                          },
                        }}
                      />
                    </div>
                  </Tooltip>
                  <Tooltip title="删除">
                    <div>
                      <HasPermi
                        bottonData={{
                          type: "link",
                          interceptor: "tmfs:configuration:del",
                          icon: <DeleteOutlined style={{ color: "red" }} />,
                          clickFn: (e) => {
                            e.stopPropagation();
                            this.showModal("deleteMap", record);
                          },
                        }}
                      />
                    </div>
                  </Tooltip>
                </Space>
              );
            } else {
              return (
                <Space>
                  <Tooltip title="修改">
                    <div>
                      <HasPermi
                        bottonData={{
                          type: "link",
                          interceptor: "tmfs:configuration:edit",
                          icon: <EditOutlined />,
                          clickFn: () => {
                            this.showModal("editMap", record);
                            this.setState({ status: "OMP岗位类型值" });
                          },
                        }}
                      />
                    </div>
                  </Tooltip>
                  <Tooltip title="删除">
                    <div>
                      <HasPermi
                        bottonData={{
                          type: "link",
                          interceptor: "tmfs:configuration:del",
                          icon: <DeleteOutlined style={{ color: "red" }} />,
                          clickFn: () => this.showModal("deleteMap", record),
                        }}
                      />
                    </div>
                  </Tooltip>
                </Space>
              );
            }
          },
        },
      ],
      relationColumns: [
        {
          title: "序号",
          dataIndex: "index",
          key: "index",
          width: 60,
          ellipsis: true,
          render: (t, r, index) =>
            `${(this.state.relationPage - 1) * this.state.relationPageSize +
            (index + 1)}`,
        },
        {
          title: "考试类型",
          dataIndex: "examCategory",
          key: "examCategory",
          width: 80,
          ellipsis: true,
          render: (text) =>
            text ? getDictionaryLabel("examType", text) : text,
        },
        {
          title: "考试级别",
          dataIndex: "examLevel",
          key: "examLevel",
          width: 80,
          ellipsis: true,
          render: (text) =>
            text ? getDictionaryLabel("examLevel", text) : text,
        },
        {
          title: "考试科目",
          dataIndex: "examSubject",
          key: "examSubject",
          ellipsis: true,
          // width: 360,
          render: (text) => {
            if (text) {
              const arr = text.split(",");
              const subjectsList = [];
              arr.forEach((item) => {
                subjectsList.push(getDictionaryLabel("examSubject", item));
              });
              return subjectsList.join(" , ");
            } else {
              return "";
            }
          },
        },
        {
          title: "创建人姓名",
          dataIndex: "createEmpName",
          key: "createEmpName",
          ellipsis: true,
          width: 100,
        },
        {
          title: "创建人工号",
          dataIndex: "createEmpNo",
          key: "createEmpNo",
          ellipsis: true,
          width: 100,
        },
        {
          title: "创建时间",
          dataIndex: "createDate",
          key: "createDate",
          ellipsis: true,
          width: 100,
        },
        {
          title: "操作",
          dataIndex: "handle",
          width: 90,
          align: "center",
          render: (_, record) => (
            <Space>
              <Tooltip title="修改">
                <div>
                  <HasPermi
                    bottonData={{
                      type: "link",
                      interceptor: "tmfs:configuration:edit",
                      icon: <EditOutlined />,
                      clickFn: () => this.showModal("editRelation", record),
                    }}
                  />
                </div>
              </Tooltip>
              <Tooltip title="删除">
                <div>
                  <HasPermi
                    bottonData={{
                      type: "link",
                      interceptor: "tmfs:configuration:del",
                      icon: <DeleteOutlined style={{ color: "red" }} />,
                      clickFn: () => this.showModal("deleteRelation", record),
                    }}
                  />
                </div>
              </Tooltip>
            </Space>
          ),
        },
      ],
      status: null,
      title: "",
      mapTitle: "",
      activeKey: "1",
      mapPage: 1,
      mapPageSize: 10,
      relationPage: 1,
      relationPageSize: 10,
      searchForm: [
        {
          type: "input",
          name: "编码",
          code: "code",
          placeholder: "请输入编码",
          maxLength: 40,
        },
        {
          type: "input",
          name: "名称",
          code: "name",
          placeholder: "请输入名称",
          maxLength: 40,
        },
      ],
      searchData: null,
    };
  }
  modifyFormRef = React.createRef(); //绑定修改信息表单
  addFormRef = React.createRef(); //绑定新增编码表单
  addParentFormRef = React.createRef(); //绑定新增父项表单
  addRelationRef = React.createRef(); //新增关系
  addMapRef = React.createRef(); //新增映射
  //获取表格数据
  getData = (page, pageSize) => {
    let data = {
      currentPage: 1,
      pageSize: 1999,
      // ...this.state.searchData
    };
    if (
      this.state.searchData &&
      this.state.searchData.code &&
      this.state.searchData.code.length
    ) {
      data.code = this.state.searchData.code;
    }
    if (
      this.state.searchData &&
      this.state.searchData.name &&
      this.state.searchData.name.length
    ) {
      data.name = this.state.searchData.name;
    }
    //发起请求
    this.setState({ tableLoading: true });
    getConfigurationData(data)
      .then((res) => {
        if (res.data.code === 200) {
          let data = res.data.data.list;
          for (const item of data) {
            item.key = item.id;
            if (item.children.length > 0) {
              for (const i of item.children) {
                i.key = i.id;
              }
            } else {
              delete item.children;
            }
          }
          this.setState({
            tableData: data,
            tableLoading: false,
          });
        } else {
          this.setState({ tableLoading: false });
          message.error(res.data.message || "查询数据失败!");
        }
      })
      .catch((error) => {
        this.setState({ tableLoading: false });
        message.error("查询数据失败!");
      });
  };
  getMapData = () => {
    this.setState({
      tableLoading: true,
      mapSelectedRow: [],
      mapSelectedRowKeys: [],
      relationSelectedRow: [],
      relationSelectedRowKeys: [],
    });
    getMapData()
      .then((res) => {
        if (res.data.code === 200) {
          let data = res.data.data;
          for (const item of data) {
            if (item.childList.length === 0) {
              delete item.childList;
            } else {
              for (const i of item.childList) {
                if (i.childList.length === 0) {
                  delete i.childList;
                } else {
                  for (const j of i.childList) {
                    if (j.childList.length === 0) {
                      delete j.childList;
                    }
                  }
                }
              }
            }
          }
          this.setState({
            tableLoading: false,
            mapData: data,
          });
        } else {
          this.setState({ tableLoading: false });
          message.error(res.data.message || "查询数据失败!");
        }
      })
      .catch((err) => {
        console.log(err);
        this.setState({ tableLoading: false });
        message.error("查询数据失败!");
      });
  };
  getRelationData = () => {
    this.setState({
      tableLoading: true,
      mapSelectedRow: [],
      mapSelectedRowKeys: [],
      relationSelectedRow: [],
      relationSelectedRowKeys: [],
    });
    getExamData()
      .then((res) => {
        if (res.data.code === 200) {
          let data = res.data.data;
          this.setState({
            tableLoading: false,
            relationData: data,
          });
        } else {
          this.setState({ tableLoading: false });
          message.error(res.data.message || "查询数据失败!");
        }
      })
      .catch((err) => {
        console.log(err);
        this.setState({ tableLoading: false });
        message.error("查询数据失败!");
      });
  };
  execSearch = (data) => {
    this.setState({ searchData: data }, () => {
      this.getData();
    });
  };
  //隐藏模态框
  hiddenModal = () => {
    this.setState(
      {
        modifyModalVisible: false, //修改的模态框
        addModalVisible: false, //添加编码的模态框
        addParentModalVisible: false, //添加父项的模态框
        deleteModalVisible: false, //删除的模态框
        addMapVisible: false,
        editMapVisible: false,
        deleteMapVisible: false,
        checkMapVisible: false,
        addRelationVisible: false,
        editRelationVisible: false,
        deleteRelationVisible: false,
        confirmLoading: false, //确认按钮异步等待
        selectedRow: {},
      },
      () => {
        // this.setState({ status: null });
        this.addRelationRef.current.setFieldsValue({
          examCategory: null,
          examLevel: null,
          examSubject: [],
        });
        this.addMapRef.current.setFieldsValue({
          postTypeCode: null,
          examTypeCode: null,
          description: null,
          content: null,
        });
      }
    );
  };
  //显示表单模态框 name:模态框名; record:行数据
  showModal = (name, record) => {
    let { ..._record } = record;
    if (name === "deleteMap" || name === "deleteRelation") {
      if (
        this.state.mapSelectedRowKeys.length == 0 &&
        this.state.relationSelectedRowKeys.length == 0 &&
        !record
      ) {
        return message.warning("请从列表选择需要删除的数据");
      }
    }
    this.setState(
      {
        selectedRow: record,
        title: name == "addMap" || name == "addRelation" ? "新增" : "修改",
        deleteModalVisible: name === "delete" ? true : false,
        modifyModalVisible: name === "modify" ? true : false,
        addModalVisible: name === "add" ? true : false,
        addParentModalVisible: name === "addParent" ? true : false,
        addMapVisible: name === "addMap" || name === "editMap" ? true : false,
        deleteMapVisible: name === "deleteMap" ? true : false,
        addRelationVisible:
          name === "addRelation" || name === "editRelation" ? true : false,
        deleteRelationVisible: name === "deleteRelation" ? true : false,
      },
      () => {
        switch (name) {
          case "modify":
            this.modifyFormRef.current.setFieldsValue(this.state.selectedRow);
            break;
          case "editMap":
            this.addMapRef.current.setFieldsValue(record);
            break;
          case "editRelation":
            _record.examSubject = _record.examSubject.split(",");
            _record.examCategory = _record.examCategory.toString();
            _record.examLevel = _record.examLevel.toString();
            this.addRelationRef.current.setFieldsValue(_record);
            break;
          default:
            break;
        }
      }
    );
  };
  //映射
  addMap = () => {
    this.addMapRef.current.validateFields().then((values, error) => {
      if (error) return;
      this.setState({ confirmLoading: true });
      let data = this.addMapRef.current.getFieldsValue();
      if (this.state.title === "新增") {
        if (this.state.selectedRow) data.parentId = this.state.selectedRow.id;
        addMapData(data)
          .then((res) => {
            if (res.data.code === 200) {
              message.success("新增成功");
              this.hiddenModal();
              this.getMapData();
            } else {
              this.setState({ confirmLoading: false });
              message.error(res.data.message || "新增失败!");
            }
          })
          .catch((err) => {
            this.setState({ confirmLoading: false });
            console.log(err);
            message.error("新增失败!");
          });
      } else if (this.state.title === "修改") {
        if (this.state.selectedRow) data.id = this.state.selectedRow.id;
        editMapData(data)
          .then((res) => {
            if (res.data.code === 200) {
              message.success("修改成功");
              this.hiddenModal();
              this.getMapData();
            } else {
              this.setState({ confirmLoading: false });
              message.error(res.data.message || "修改失败!");
            }
          })
          .catch((err) => {
            this.setState({ confirmLoading: false });
            console.log(err);
            message.error("修改失败!");
          });
      }
    });
  };
  deleteMap = () => {
    this.setState({ confirmLoading: true });
    let ids = [];
    if (this.state.selectedRow) {
      ids = [this.state.selectedRow.id];
    } else {
      ids = this.state.mapSelectedRowKeys;
    }
    // return
    deleteMapData(ids)
      .then((res) => {
        if (res.data.code === 200) {
          message.success("删除成功");
          this.hiddenModal();
          this.getMapData();
        } else {
          this.setState({ confirmLoading: false });
          message.error(res.data.message || "删除失败!");
        }
      })
      .catch((err) => {
        this.setState({ confirmLoading: false });
        console.log(err);
        message.error("删除失败!");
      });
  };
  onMapSelectChange = (mapSelectedRowKeys, mapSelectedRow) => {
    this.setState({ mapSelectedRowKeys, mapSelectedRow });
  };
  onRelationSelectChange = (relationSelectedRowKeys, relationSelectedRow) => {
    this.setState({ relationSelectedRowKeys, relationSelectedRow });
  };
  mapPageChange = (mapPage, mapPageSize) => {
    this.setState({ mapPage, mapPageSize });
  };
  relationPageChange = (relationPage, relationPageSize) => {
    this.setState({ relationPage, relationPageSize });
  };
  //确定添加父项
  handleAddParent = () => {
    let formData = this.addParentFormRef.current.getFieldsValue();
    //表单验证
    this.addParentFormRef.current.validateFields().then((values, error) => {
      if (error) return;
      this.setState({ confirmLoading: true });
      let sort;
      if (formData.sort) {
        sort = formData.sort;
      } else {
        sort = 0;
      }
      let data = {
        code: formData.code,
        name: formData.name,
        description: formData.description,
        sort: sort,
      };
      //发起请求
      addConfigurationData(data)
        .then((res) => {
          if (res.data.code === 200) {
            this.getData();
            this.hiddenModal();
            message.success("新增成功");
          } else {
            message.error(res.data.message || "新增失败!");
          }
        })
        .catch((error) => {
          message.error("新增失败!");
        });
    });
  };
  //确定添加编码
  handleAdd = () => {
    let formData = this.addFormRef.current.getFieldsValue();
    this.addFormRef.current.validateFields().then((values, error) => {
      if (error) return;
      let sort;
      if (formData.sort) {
        sort = formData.sort;
      } else {
        sort = 0;
      }
      this.setState({ confirmLoading: true });
      let data = {
        code: formData.code,
        name: formData.name,
        description: formData.description,
        parentId: this.state.selectedRow.id,
        sort: sort,
      };
      addConfigurationData(data)
        .then((res) => {
          if (res.data.code === 200) {
            this.getData();
            this.hiddenModal();
            message.success("新增成功");
          } else {
            message.error(res.data.message || "新增失败!");
          }
        })
        .catch((error) => {
          message.error("新增失败!");
        });
    });
  };
  //确认修改信息
  handleModify = () => {
    let formData = this.modifyFormRef.current.getFieldsValue();
    this.modifyFormRef.current.validateFields().then((values, error) => {
      if (error) return;
      this.setState({ confirmLoading: true });
      let sort;
      if (formData.sort) {
        sort = formData.sort;
      } else {
        sort = 0;
      }
      let data = {
        code: this.state.selectedRow.code,
        description: formData.description,
        id: this.state.selectedRow.id,
        name: formData.name,
        parentId: this.state.selectedRow.parentId,
        sort: sort,
      };
      editConfigurationData(data)
        .then((res) => {
          if (res.data.code === 200) {
            this.getData();
            this.hiddenModal();
            message.success("修改成功");
          } else {
            message.error(res.data.message || "修改失败!");
          }
        })
        .catch((err) => {
          message.error("修改失败!");
        });
    });
  };
  //确定删除
  handleDelete = () => {
    this.setState({ confirmLoading: true });
    deleteConfigurationData(this.state.selectedRow.id)
      .then((res) => {
        if (res.data.code === 200) {
          this.getData();
          this.hiddenModal();
          message.success("删除成功");
        } else {
          message.error(res.data.message || "删除失败!");
        }
      })
      .catch((err) => {
        message.error("删除失败!");
      });
  };
  componentWillMount () {
    //获取全部数据
    this.getData(1, 1000);
  }
  componentDidMount () { }
  //组件销毁时取消setState
  componentWillUnmount () {
    this.setState = (state, callback) => {
      return;
    };
  }
  render () {
    return (
      <div id="evaluate">
        <div className="myProjectsBody">
          <div className="tabstyle">
            <div className="bigContent1">
              <AdvancedSearchForm
                execSearch={this.execSearch}
                formData={this.state.searchForm}
              />
            </div>
            {/* <div className="segmentationDiv"></div> */}
            <div className="bigContent1" id="projectDetail">
              <div className="operatingDiv">
                <Tooltip title="添加枚举类型">
                  <HasPermi
                    bottonData={{
                      type: "primary",
                      interceptor: "tmfs:configuration:add",
                      icon: <PlusOutlined />,
                      clickFn: () =>
                        this.showModal("addParent", this.state.selectedRow),
                      text: "新增",
                    }}
                  />
                </Tooltip>
                <div className="tableDiff">
                  <Table
                    rowKey="id"
                    loading={this.state.tableLoading}
                    style={{ marginTop: 10 }}
                    columns={this.state.tableColumns}
                    dataSource={this.state.tableData}
                    pagination={{
                      showSizeChanger: true,
                      showTotal: (total) => "共 " + total + " 条",
                    }}
                    bordered
                    expandable={{ expandRowByClick: true }}
                  ></Table>
                </div>
              </div>
            </div>
          </div>
        </div>
        {/* 映射模态框 */}
        {/* 新增 */}
        <NewModal
          modalOptions={{
            width: "400px",
            title: this.state.title + this.state.status,
            destroyOnClose: true,
            forceRender: true,
            onCancel: this.hiddenModal,
            visible: this.state.addMapVisible,
          }}
          buttonOptions={{
            position: "center",
            btnList: [
              {
                key: 0,
                onClick: this.addMap,
                text: "确认",
                type: "primary",
                loading: this.state.confirmLoading,
              },
              {
                key: 1,
                onClick: this.hiddenModal,
                text: "取消",
              },
            ],
          }}
        >
          {this.state.status == "OMP岗位映射" ? (
            <Form name="addForm" ref={this.addMapRef} labelCol={{ span: 6 }}>
              <Form.Item
                label="岗位类型"
                name="postTypeCode"
                rules={[{ required: true, message: "请选择岗位类型" }]}
              >
                <Select>
                  {getDictionaryLabel("postCategory").map((item) => {
                    return (
                      <Select.Option value={item.code} key={item.code}>
                        {item.label}
                      </Select.Option>
                    );
                  })}
                </Select>
              </Form.Item>
              <Form.Item
                label="考试类型"
                name="examTypeCode"
                rules={[{ required: true, message: "请选择考试类型" }]}
              >
                <Select>
                  {getExamDictionaryLabel("examType").map((item) => {
                    return item.code == 0 ? (
                      ""
                    ) : (
                      <Select.Option value={item.code} key={item.code}>
                        {item.label}
                      </Select.Option>
                    );
                  })}
                </Select>
              </Form.Item>
              <Form.Item
                label="描述"
                name="description"
              // rules={[{ required: true, message: "请输入" }]}
              >
                <Input maxLength={20} />
              </Form.Item>
            </Form>
          ) : (
            <Form name="addForm" ref={this.addMapRef} labelCol={{ span: 4 }}>
              <Form.Item
                label="名称"
                name="content"
                rules={[{ required: true, message: "请输入名称" }]}
              >
                <Input maxLength={20} />
              </Form.Item>
              <Form.Item
                label="描述"
                name="description"
              // rules={[{ required: true, message: "请输入" }]}
              >
                <Input maxLength={20} />
              </Form.Item>
            </Form>
          )}
        </NewModal>
        {/* 删除 */}
        <NewModal
          modalOptions={{
            width: "420px",
            title: "删除提示",
            onCancel: this.hiddenModal,
            visible: this.state.deleteMapVisible,
          }}
          buttonOptions={{
            position: "right",
            btnList: [
              {
                key: 1,
                onClick: this.hiddenModal,
                text: "取消",
              },
              {
                key: 0,
                onClick: this.deleteMap,
                text: "确认删除",
                type: "primary",
                loading: this.state.confirmLoading,
              },
            ],
          }}
        >
          <DeleteFilled
            style={{
              fontSize: "28px",
              color: "#e00",
              float: "left",
              backgroundColor: "#f002",
              padding: 8,
              borderRadius: "50%",
            }}
          />
          <div
            style={{
              fontSize: 14,
              marginLeft: 60,
              fontWeight: 700,
              lineHeight: "44px",
            }}
          >
            删除后数据不可恢复，请确认是否删除选中条目？
          </div>
        </NewModal>
        {/* 修改 */}

        {/* 关系新增 */}
        <NewModal
          modalOptions={{
            width: "500px",
            title: this.state.title,
            destroyOnClose: true,
            forceRender: true,
            onCancel: this.hiddenModal,
            visible: this.state.addRelationVisible,
          }}
          buttonOptions={{
            position: "center",
            btnList: [
              {
                key: 0,
                onClick: this.addRelation,
                text: "确认",
                type: "primary",
                loading: this.state.confirmLoading,
              },
              {
                key: 1,
                onClick: this.hiddenModal,
                text: "取消",
              },
            ],
          }}
        >
          <Form name="addForm" ref={this.addRelationRef}>
            <Form.Item
              label="考试类型"
              name="examCategory"
              rules={[{ required: true, message: "请选择考试类型" }]}
            >
              <Select placeholder="请选择">
                {getDictionaryLabel("examType").map((item) => {
                  return (
                    <Select.Option value={item.code} key={item.code}>
                      {item.label}
                    </Select.Option>
                  );
                })}
              </Select>
            </Form.Item>
            <Form.Item
              label="考试级别"
              name="examLevel"
              rules={[{ required: true, message: "请选择考试级别" }]}
            >
              <Select placeholder="请选择">
                {getDictionaryLabel("examLevel").map((item) => {
                  return (
                    <Select.Option value={item.code} key={item.code}>
                      {item.label}
                    </Select.Option>
                  );
                })}
              </Select>
            </Form.Item>
            <Form.Item
              label="考试科目"
              name="examSubject"
              rules={[{ required: true, message: "请选择考试科目" }]}
            >
              <Select
                placeholder="请选择"
                mode={"multiple"}
                optionFilterProp="children"
                allowClear
              >
                {getDictionaryLabel("examSubject").map((item) => {
                  return (
                    <Select.Option value={item.code} key={item.code}>
                      {item.label}
                    </Select.Option>
                  );
                })}
              </Select>
            </Form.Item>
          </Form>
        </NewModal>
        {/* 关系删除 */}
        <NewModal
          modalOptions={{
            width: "420px",
            title: "删除提示",
            onCancel: this.hiddenModal,
            visible: this.state.deleteRelationVisible,
          }}
          buttonOptions={{
            position: "right",
            btnList: [
              {
                key: 1,
                onClick: this.hiddenModal,
                text: "取消",
              },
              {
                key: 0,
                onClick: this.deleteRelation,
                text: "确认删除",
                type: "primary",
                loading: this.state.confirmLoading,
              },
            ],
          }}
        >
          <DeleteFilled
            style={{
              fontSize: "28px",
              color: "#e00",
              float: "left",
              backgroundColor: "#f002",
              padding: 8,
              borderRadius: "50%",
            }}
          />
          <div
            style={{
              fontSize: 14,
              marginLeft: 60,
              fontWeight: 700,
              lineHeight: "44px",
            }}
          >
            删除后数据不可恢复，请确认是否删除选中条目？
          </div>
        </NewModal>

        {/* 枚举值删除 */}
        <NewModal
          modalOptions={{
            width: "420px",
            title: "删除提示",
            onCancel: this.hiddenModal,
            visible: this.state.deleteModalVisible,
          }}
          buttonOptions={{
            position: "right",
            btnList: [
              {
                key: 1,
                onClick: this.hiddenModal,
                text: "取消",
              },
              {
                key: 0,
                onClick: this.handleDelete,
                text: "确认删除",
                type: "primary",
                loading: this.state.confirmLoading,
              },
            ],
          }}
        >
          <DeleteFilled
            style={{
              fontSize: "28px",
              color: "#e00",
              float: "left",
              backgroundColor: "#f002",
              padding: 8,
              borderRadius: "50%",
            }}
          />
          <div style={{ fontSize: 14, marginLeft: 60, fontWeight: 700 }}>
            {this.state.selectedRow
              ? "确认删除【" + this.state.selectedRow.code + "】？"
              : " "}
            <p style={{ color: "red" }}>
              删除后数据不可恢复，请确认是否删除选中条目？
            </p>
          </div>
        </NewModal>
        {/* 枚举值修改 */}
        <NewModal
          modalOptions={{
            width: "400px",
            title: "修改",
            forceRender: true,
            onCancel: this.hiddenModal,
            visible: this.state.modifyModalVisible,
          }}
          buttonOptions={{
            position: "center",
            btnList: [
              {
                key: 0,
                onClick: this.handleModify,
                text: "确认",
                type: "primary",
                loading: this.state.confirmLoading,
              },
              {
                key: 1,
                onClick: this.hiddenModal,
                text: "取消",
              },
            ],
          }}
        >
          <Form
            name="modifyForm"
            ref={this.modifyFormRef}
            labelCol={{ span: 4, offset: 0 }}
          >
            <Form.Item label="编码">
              {this.state.selectedRow ? this.state.selectedRow.code : ""}
            </Form.Item>
            <Form.Item
              label="名称"
              name="name"
              rules={[
                { required: true, message: "请输入名称" },
                { max: 40, message: "名称不能大于40个字符" },
              ]}
            >
              <Input maxLength={40}></Input>
            </Form.Item>
            <Form.Item
              label="排序"
              name="sort"
              rules={[
                {
                  pattern: new RegExp(/^[0-9]\d*$/, "g"),
                  message: "请输入大于等于0的整数",
                },
              ]}
            >
              <InputNumber
                min={0}
                style={{
                  width: "100%",
                }}
                maxLength={10}
              />
            </Form.Item>
            <Form.Item
              label="描述"
              name="description"
              rules={[{ max: 100, message: "描述不能大于100个字符" }]}
            >
              <Input maxLength={100} />
            </Form.Item>
          </Form>
        </NewModal>
        {/* 枚举值新增编码 */}
        <NewModal
          modalOptions={{
            width: "400px",
            title: "新增",
            destroyOnClose: true,
            onCancel: this.hiddenModal,
            visible: this.state.addModalVisible,
          }}
          buttonOptions={{
            position: "center",
            btnList: [
              {
                key: 0,
                onClick: this.handleAdd,
                text: "确认",
                type: "primary",
                loading: this.state.confirmLoading,
              },
              {
                key: 1,
                onClick: this.hiddenModal,
                text: "取消",
              },
            ],
          }}
        >
          <Form
            name="addForm"
            ref={this.addFormRef}
            labelCol={{ span: 4, offset: 0 }}
          >
            <Form.Item
              label="编码"
              name="code"
              rules={[
                { required: true, message: "请输入编码值" },
                { max: 40, message: "编码不能大于40个字符" },
              ]}
            >
              <Input maxLength={40}></Input>
            </Form.Item>
            <Form.Item
              label="名称"
              name="name"
              rules={[
                { required: true, message: "请输入名称" },
                { max: 40, message: "名称不能大于40个字符" },
              ]}
            >
              <Input maxLength={40}></Input>
            </Form.Item>
            <Form.Item
              label="排序"
              name="sort"
              rules={[
                {
                  pattern: new RegExp(/^[0-9]\d*$/, "g"),
                  message: "请输入大于等于0的整数",
                },
              ]}
            >
              <InputNumber
                maxLength={10}
                min={0}
                style={{
                  width: "100%",
                }}
              />
            </Form.Item>
            <Form.Item
              label="描述"
              name="description"
              rules={[{ max: 100, message: "描述不能大于100个字符" }]}
            >
              <Input maxLength={100}></Input>
            </Form.Item>
          </Form>
        </NewModal>
        {/* 枚举值新增枚举类型 */}
        <NewModal
          modalOptions={{
            width: "400px",
            title: "新增",
            destroyOnClose: true,
            onCancel: this.hiddenModal,
            visible: this.state.addParentModalVisible,
          }}
          buttonOptions={{
            position: "center",
            btnList: [
              {
                key: 0,
                onClick: this.handleAddParent,
                text: "确认",
                type: "primary",
                loading: this.state.confirmLoading,
              },
              {
                key: 1,
                onClick: this.hiddenModal,
                text: "取消",
              },
            ],
          }}
        >
          <Form
            name="addForm"
            ref={this.addParentFormRef}
            labelAlign="right"
            labelCol={{ span: 4, offset: 0 }}
          >
            <Form.Item
              label="编码"
              name="code"
              rules={[
                { required: true, message: "请输入编码值" },
                { max: 40, message: "编码不能大于40个字符" },
              ]}
            >
              <Input maxLength={40}></Input>
            </Form.Item>
            <Form.Item
              label="名称"
              name="name"
              rules={[
                { required: true, message: "请输入名称" },
                { max: 40, message: "名称不能大于40个字符" },
              ]}
            >
              <Input maxLength={40}></Input>
            </Form.Item>
            <Form.Item
              label="排序"
              name="sort"
              rules={[
                {
                  pattern: new RegExp(/^[0-9]\d*$/, "g"),
                  message: "请输入大于等于0的整数",
                },
              ]}
            >
              <InputNumber
                maxLength={10}
                min={0}
                style={{
                  width: "100%",
                }}
              />
            </Form.Item>
            <Form.Item
              label="描述"
              name="description"
              rules={[{ max: 100, message: "描述不能大于100个字符" }]}
            >
              <Input maxLength={100}></Input>
            </Form.Item>
          </Form>
        </NewModal>
      </div>
    );
  }
}
export default Index;
